function moveEntity(entity, axis, modifier) {
    if(axis == 0)
        axis = modifier;
    entity.pixelsToMove -= 1;
    if(entity.pixelsToMove <0) {
        entity.moving = false
        axis = 0;
        entity.pixelsToMove = 16;
        var endPoint = getTileEntityIs(entity);
        // see if stepped into event
        searchForEvent(endPoint.x, endPoint.y);
    }
    return axis;
}

function getTileEntityIs(entity) {
    return {
        x : Math.round(entity.pos.x/16),
        y : Math.round((entity.pos.y/16)+0.5)
    };
}

function canMove(xMod, yMod, entity) {
    var pos = getTileEntityIs(entity);
     //alert(pos.x+xMod + " - "+pos.y+yMod);
    var nextTile = me.game.currentLevel.getLayerByName("collision").getTile(pos.x*16+(xMod*16), pos.y*16+(yMod*16));
    if(nextTile===null || nextTile==undefined) return true;
    if(nextTile.tileId!=1) {
        return true;
    }
    return false;
}